<?php
defined('IN_IA') or exit ('Access Denied');

class Core extends WeModuleSite
{
  
    public function getMainMenu()
    {
        global $_W, $_GPC;

        $do = $_GPC['do'];
        $navemenu = array();
        $cur_color = ' style="color:#d9534f;" ';
      
//             $navemenu[0] = array(
//                 'title' => '<a href="index.php?c=site&a=entry&op=display&do=gaikuangdata&m=zh_jypx" class="panel-title wytitle" id="yframe-0"><icon style="color:#8d8d8d;" class="fa fa-cubes"></icon>  数据统计</a>',
// //                'items' => array(
// //                    0 => $this->createMainMenu('数据概况 ', $do, 'gaikuangdata', ''),
// //                    // 0 => $this->createMainMenu('门店回收站 ', $do, 'yg4', ''),
// //                )
//             );
             $navemenu[4] = array(
                'title' => '<a href="index.php?c=site&a=entry&op=display&do=slide&m=zh_jypx" class="panel-title wytitle" id="yframe-4"><icon style="color:#8d8d8d;" class="fa fa-recycle"></icon> 页面管理</a>',
                'items' => array(
                    2 => $this->createMainMenu('轮播图管理 ', $do, 'slide', ''),
                    0 => $this->createMainMenu('文章管理 ', $do, 'articles', ''),
                    // 1 => $this->createMainMenu('添加文章', $do, 'addarticles', ''),
                    // 3 => $this->createMainMenu('添加轮播图', $do, 'addslide', ''),
                )
            );
            $navemenu[1] = array(
                'title' => '<a href="index.php?c=site&a=entry&op=display&do=school&m=zh_jypx" class="panel-title wytitle" id="yframe-1"><icon style="color:#8d8d8d;" class="fa fa-bars"></icon>  校区管理</a>',
                'items' => array(
                     0 => $this->createMainMenu('校区管理 ', $do, 'school', ''),
                     // 1 => $this->createMainMenu('添加校区 ', $do, 'addschool', ''),
                )
            );
            $navemenu[11] = array(
               'title' => '<a href="index.php?c=site&a=entry&op=display&do=coursecate&m=zh_jypx" class="panel-title wytitle" id="yframe-11"><icon style="color:#8d8d8d;" class="fa fa-globe"></icon> 课程管理</a>',
               'items' => array(
                    0 => $this->createMainMenu('学级管理 ', $do, 'coursecate', ''),
                    // 1 => $this->createMainMenu('添加学级', $do, 'addcoursecate', ''),
                    2 => $this->createMainMenu('课程管理', $do, 'subject', ''),
                    // 3 => $this->createMainMenu('添加课程', $do, 'addsubject', ''),
                    // 4 => $this->createMainMenu('课节管理', $do, 'unit', ''),
                    // 5 => $this->createMainMenu('添加课节', $do, 'addunit', ''),
                    4 => $this->createMainMenu('班级管理', $do, 'class', ''),
                    // 5 => $this->createMainMenu('添加班级', $do, 'addclass', ''),
               )
           );
               $navemenu[5] = array(
                'title' => '<a href="index.php?c=site&a=entry&op=display&do=unit&m=zh_jypx" class="panel-title wytitle" id="yframe-5"><icon style="color:#8d8d8d;" class="fa fa-pencil-square-o"></icon> 作业管理</a>',
                'items' => array(
                    0 => $this->createMainMenu('课节管理 ', $do, 'unit', ''),
                    // 1 => $this->createMainMenu('添加课节', $do, 'addunit', ''),
                    2 => $this->createMainMenu('批改作业管理', $do, 'examinetask', ''),
                )
            );
             $navemenu[12] = array(
                'title' => '<a href="index.php?c=site&a=entry&op=display&do=user&m=zh_jypx" class="panel-title wytitle" id="yframe-12"><icon style="color:#8d8d8d;" class="fa fa-comment-o"></icon>  用户管理</a>',
                'items' => array(
                    0 => $this->createMainMenu('用户管理 ', $do, 'user', ''),
                    1 => $this->createMainMenu('学员管理', $do, 'students', ''),
                    // 2 => $this->createMainMenu('访客管理 ', $do, 'visitor', ''),
                )
            );
             $navemenu[6] = array(
                'title' => '<a href="index.php?c=site&a=entry&op=display&do=teacher&m=zh_jypx" class="panel-title wytitle" id="yframe-6"><icon style="color:#8d8d8d;" class="fa fa-user"></icon>  老师管理</a>',
                'items' => array(
                    0 => $this->createMainMenu('老师管理 ', $do, 'teacher', ''),
                    // 1 => $this->createMainMenu('添加老师', $do, 'addteacher', ''),
                    // 2 => $this->createMainMenu('访客管理 ', $do, 'visitor', ''),
                )
            );
            //  $navemenu[2] = array(
            //     'title' => '<a href="index.php?c=site&a=entry&op=display&do=ranking&m=zh_jypx" class="panel-title wytitle" id="yframe-2"><icon style="color:#8d8d8d;" class="fa fa-life-ring"></icon>  课程分类</a>',
            //     'items' => array(
            //          0 => $this->createMainMenu('分类管理 ', $do, 'coursetype', ''),
            //          1 => $this->createMainMenu('添加分类', $do, 'addcoursetype', ''),
            //     )
            // );

            
            
          

           $navemenu[9] = array(
                   'title' => '<a href="index.php?c=site&a=entry&op=display&do=prize&m=zh_jypx" class="panel-title wytitle" id="yframe-9"><icon style="color:#8d8d8d;" class="fa fa-star-half-o"></icon>奖品管理</a>',
                   'items' => array(
                       0 => $this->createMainMenu('奖品管理', $do, 'prize', ''),
                       // 1 => $this->createMainMenu('添加奖品', $do, 'addprize', ''),
                       2 => $this->createMainMenu('核销员管理', $do, 'hxlist', ''),
                       // 3 => $this->createMainMenu('奖品发放记录', $do, 'prizerecord', ''),
                       4 => $this->createMainMenu('奖品兑换规则', $do, 'prizerule', ''),
                   )
               );

           

          
           
            // $navemenu[13] = array(
            //      'title' => '<a href="index.php?c=site&a=entry&op=display&do=user&m=zh_jypx" class="panel-title wytitle" id="yframe-12"><icon style="color:#8d8d8d;" class="fa fa-user"></icon>  学员管理</a>',
                
            // );
           
            $navemenu[14] = array(
                'title' => '<a href="index.php?c=site&a=entry&op=display&do=peiz&m=zh_jypx" class="panel-title wytitle" id="yframe-14"><icon style="color:#8d8d8d;" class="fa fa-cog"></icon>  系统设置</a>',
                'items' => array(
                    // 0 => $this->createMainMenu('基本信息 ', $do, 'settings', ''),
                    1 => $this->createMainMenu('小程序配置', $do, 'peiz', ''),
                    // 2 => $this->createMainMenu('支付配置', $do, 'pay', ''),
                    4 => $this->createMainMenu('短信配置', $do, 'code', ''),
                    // 5 => $this->createMainMenu('帮助中心', $do, 'help', ''),                      
                    // 4 => $this->createMainMenu('系统更新', $do, 'heli', ''),
                    // 7 => $this->createMainMenu('版权设置', $do, 'banquanset', ''),   
                )
            );
            
        
        return $navemenu;
    }


    function createCoverMenu($title, $method, $op, $icon = "fa-image", $color = '#d9534f')
    {
        global $_GPC, $_W;
        $cur_op = $_GPC['op'];
        $color = ' style="color:'.$color.';" ';
        return array('title' => $title, 'url' => $op != $cur_op ? $this->createWebUrl($method, array('op' => $op)) : '',
            'active' => $op == $cur_op ? ' active' : '',
            'append' => array(
                'title' => '<i class="fa fa-angle-right"></i>',
            )
        );
    }

    function createMainMenu($title, $do, $method, $icon = "fa-image", $color = '')
    {
        $color = ' style="color:'.$color.';" ';

        return array('title' => $title, 'url' => $do != $method ? $this->createWebUrl($method, array('op' => 'display')) : '',
            'active' => $do == $method ? ' active' : '',
            'append' => array(
                'title' => '<i '.$color.' class="fa fa-angle-right"></i>',
            )
        );
    }

  /*  function createSubMenu($title, $do, $method, $icon = "fa-image", $color = '#d9534f', $storeid)
    {
        $color = ' style="color:'.$color.';" ';
        $url = $this->createWebUrl($method, array('op' => 'display', 'storeid' => $storeid));
        if ($method == 'stores') {
            $url = $this->createWebUrl('stores', array('op' => 'post', 'id' => $storeid, 'storeid' => $storeid));
        }

        return array('title' => $title, 'url' => $do != $method ? $url : '',
            'active' => $do == $method ? ' active' : '',
            'append' => array(
                'title' => '<i class="fa '.$icon.'"></i>',
            )
        );
    }

*/
    function createWebUrl2($do, $query = array()) {
        $query['do'] = $do;
        $query['m'] = strtolower($this->modulename);
      
        return $this->wurl('site/entry', $query);
    }

    function wurl($segment, $params = array()) {
      
    list($controller, $action, $do) = explode('/', $segment);
    $url = './zhstore.php?';
    if (!empty($controller)) {
        $url .= "c={$controller}&";
    }
    if (!empty($action)) {
        $url .= "a={$action}&";
    }
    if (!empty($do)) {
        $url .= "do={$do}&";
    }
    if (!empty($params)) {
        $queryString = http_build_query($params, '', '&');
        $url .= $queryString;
    }
    return $url;
}

        function createSubMenu($title, $do, $method, $icon = "fa-image", $color = '#d9534f', $storeid)
    {
        $color = ' style="color:'.$color.';" ';
        $url = $this->createWebUrl2($method, array('op' => 'display', 'storeid' => $storeid));
        if ($method == 'stores2') {
            $url = $this->createWebUrl2('stores2', array('op' => 'post', 'id' => $storeid, 'storeid' => $storeid));
        }



        return array('title' => $title, 'url' => $do != $method ? $url : '',
            'active' => $do == $method ? ' active' : '',
            'append' => array(
                'title' => '<i class="fa '.$icon.'"></i>',
            )
        );
    }
    public function getStoreById($id)
    {
        $store = pdo_fetch("SELECT * FROM " . tablename('snx_store') . " WHERE id=:id LIMIT 1", array(':id' => $id));
        return $store;
    }


    public function set_tabbar($action, $storeid)
    {
        $actions_titles = $this->actions_titles;
        $html = '<ul class="nav nav-tabs">';
        foreach ($actions_titles as $key => $value) {
            if ($key == 'stores') {
                $url = $this->createWebUrl('stores', array('op' => 'post', 'id' => $storeid));
            } else {
                $url = $this->createWebUrl($key, array('op' => 'display', 'storeid' => $storeid));
            }

            $html .= '<li class="' . ($key == $action ? 'active' : '') . '"><a href="' . $url . '">' . $value . '</a></li>';
        }
        $html .= '</ul>';
        return $html;
    }
}